const axios = require("axios");
const { apiHost } = require("../config");
/**
 * 响应 GET 请求（响应微信配置时的签名检查请求）
 */
async function list(ctx, next) {
  const data = [
    {
      dateAdd: "2017-09-12 11:07:32",
      icon: "",
      id: 1872,
      isUse: true,
      key: "1",
      level: 1,
      name: "上装",
      paixu: 0,
      pid: 0,
      type: "",
      userId: 951
    },
    {
      dateAdd: "2017-09-12 11:07:48",
      icon: "",
      id: 1873,
      isUse: true,
      key: "2",
      level: 1,
      name: "裤装",
      paixu: 0,
      pid: 0,
      type: "",
      userId: 951
    },
    {
      dateAdd: "2017-09-12 11:08:02",
      icon: "",
      id: 1874,
      isUse: true,
      key: "3",
      level: 1,
      name: "家居内衣",
      paixu: 0,
      pid: 0,
      type: "",
      userId: 951
    },
    {
      dateAdd: "2017-09-12 11:08:14",
      icon: "",
      id: 1875,
      isUse: true,
      key: "4",
      level: 1,
      name: "特价区",
      paixu: 0,
      pid: 0,
      type: "",
      userId: 951
    },
    {
      dateAdd: "2017-09-13 09:37:53",
      icon: "",
      id: 1906,
      isUse: true,
      key: "5",
      level: 1,
      name: "裙装",
      paixu: 0,
      pid: 0,
      type: "",
      userId: 951
    },
    {
      dateAdd: "2017-09-13 10:06:52",
      icon: "",
      id: 1907,
      isUse: true,
      key: "6",
      level: 1,
      name: "套装",
      paixu: 0,
      pid: 0,
      type: "",
      userId: 951
    },
    {
      dateAdd: "2017-09-16 14:03:08",
      icon: "",
      id: 2016,
      isUse: true,
      key: "7",
      level: 1,
      name: "外套",
      paixu: 0,
      pid: 0,
      type: "",
      userId: 951
    },
    {
      dateAdd: "2017-09-17 19:55:09",
      icon: "",
      id: 2054,
      isUse: true,
      key: "8",
      level: 1,
      name: "秒杀",
      paixu: 0,
      pid: 0,
      type: "",
      userId: 951
    },
    {
      dateAdd: "2017-09-25 09:07:38",
      icon: "",
      id: 2245,
      isUse: true,
      key: "9",
      level: 1,
      name: "内裤",
      paixu: 0,
      pid: 0,
      type: "",
      userId: 951
    },
    {
      dateAdd: "2017-09-25 09:07:58",
      icon: "",
      id: 2246,
      isUse: true,
      key: "10",
      level: 1,
      name: "袜子",
      paixu: 0,
      pid: 0,
      type: "",
      userId: 951
    },
    {
      dateAdd: "2017-10-18 11:13:56",
      icon: "",
      id: 2787,
      isUse: true,
      key: "11",
      level: 1,
      name: "鞋",
      paixu: 0,
      pid: 0,
      type: "",
      userId: 951
    }
  ];
  ctx.body = data;
}

async function findById(ctx, next) {
  // 检查签名，确认是微信发出的请求
  const { id } = ctx.params;
  //const { data } = await axios.get(apiHost + "/topics/" + id);
  const data = {
    dateAdd: "2017-10-18 11:13:56",
    icon: "",
    id: 2787,
    isUse: true,
    key: "11",
    level: 1,
    name: "鞋",
    paixu: 0,
    pid: 0,
    type: "",
    userId: 951
  };
  ctx.body = data;
}

module.exports = {
  findById,
  list
};
